<template>
  <el-form :model="cfgForm"  :rules="cfgrules" status-icon  ref="cfgForm" label-width="20%">
    <el-form-item label="配置类别">
      <el-input v-model="caption" :disabled='true'></el-input>
    </el-form-item>
    <el-form-item label="配置项" prop="checkConfig">
      <el-input v-model="cfgForm.editConfig" auto-complete="off" placeholder="请输入配置内容"></el-input>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  name: "SysItemConfig",
  props: ['caption','config'],
  data(router) {
    var required = (rule, value, callback) => {
        if (value === '') {
          callback(new Error('不能为空,请输入'));
        } else {
          callback();
        }
      };
    return {
      cfgForm:{
        editConfig:'',
      },
      cfgrules: {
          checkConfig: [
            { validator: required, trigger: 'blur' }
          ]
        }
    };
  },
  created: function() {
    if(this.config)
      this.cfgForm.editConfig = this.config
  },
  mounted: function() {},
  methods: {
    validate:function(){
      this.$refs.cfgForm.validate((valid) => {
          if (!valid) {
            console.log('error submit!!')
            return false
          }
          return true
        });
    },
    getData(){
      this.validate()
      if(!this.cfgForm.editConfig){
        this.$message({
          message: '请填写配置信息',
          type: 'error'
        });
        return null
      }
      return this.cfgForm.editConfig
    }
  }
};
</script>

